//
// Created by dave on 18-7-29.
//
#pragma once

#include <string>
#include <algorithm>
#include "../msg_body.h"
#include "../data_utils.h"

class term_register_resp : public msg_body {
public:
    std::vector<unsigned char> encode() override {
        std::vector<unsigned char> ret;
        write_word(ret, term_seq_no);
        ret.push_back(result);
        for_each(auth.cbegin(), auth.cend(), [&ret](const char ch) {
            ret.push_back(ch);
        });
        return ret;
    }

    unsigned short get_term_seq_no() { return term_seq_no; }
    void set_term_seq_no(unsigned short term_seq_no) { this->term_seq_no = term_seq_no; }
    char get_result() { return result; }
    void set_result(char result) { this->result = result; }
    std::string get_auth() { return auth; }
    void set_auth(std::string auth) { this->auth = auth; }

private:
    unsigned short term_seq_no;
    char result;
    std::string auth;
};